package cn.strive.eams.fixedassets.controller;

import cn.strive.eams.base.response.JsonResult;
import cn.strive.eams.fixedassets.pojo.dto.FixedassetsQuerry;
import cn.strive.eams.fixedassets.pojo.dto.FixedassetsSaveParam;
import cn.strive.eams.fixedassets.pojo.dto.FixesAssetsQuery;
import cn.strive.eams.fixedassets.pojo.vo.FixedassetsVO;
import cn.strive.eams.fixedassets.service.FixedassetsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/fixed")
@Api(tags = "固定资产管理")
public class FixedassetsController {
    @Autowired
    FixedassetsService fixedassetsService;

    @GetMapping("/select")
    public JsonResult selectFixedassets(FixedassetsQuerry fixedassetsQuerry){
        log.debug("查询所有资产信息:fixedassetsQuerry={}",fixedassetsQuerry);
        List<FixedassetsVO> list = fixedassetsService.selectFixedassets(fixedassetsQuerry);
        return JsonResult.ok(list);
    }


    @GetMapping("/selectById")
    public JsonResult selectById(FixedassetsQuerry fixedassetsQuerry){
        log.debug("查询所有资产信息:fixedassetsQuerry={}",fixedassetsQuerry);
        List<FixedassetsVO> list = fixedassetsService.selectById(fixedassetsQuerry);
        return JsonResult.ok(list);
    }
    @PostMapping("/save")
    public JsonResult saveFixedassets(FixedassetsSaveParam fixedassetsSaveParam){
        log.debug("保存资产信息:fixedassetsVO={}",fixedassetsSaveParam);
        fixedassetsService.saveFixedassets(fixedassetsSaveParam);
        return JsonResult.ok();
    }
    @DeleteMapping("/delete/{id}")
    public JsonResult deleteFixedassets(@PathVariable Long id){
        log.debug("删除资产信息:id={}",id);
        fixedassetsService.deleteFixedassets(id);
        return JsonResult.ok();
    }

    @GetMapping("/select/home")
    @ApiOperation(value = "查询非房间里的资产")
    public JsonResult selectHomeAsset(FixesAssetsQuery fixesAssetsQuery){
        log.debug("查询房间的资产信息:fixesAssetsQuery={}",fixesAssetsQuery);
        List<FixedassetsVO> list = fixedassetsService.selectHomeAsset(fixesAssetsQuery);
        return JsonResult.ok(list);
    }
}